<template>
	<view class="" style="background: #F2F5FF;    min-height: 100vh;">
		<view class="mineBox">
			<view class="bgBox"></view>
			<view class="mineMain">
				<view class="avatarUrl">
					<button type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar">
						<image :src="avatarUrl ? avatarUrl : 'http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg'" class="refreshIcon"></image>
					</button>
				</view>

				<view class="nameBox">用户名称：{{ userName }}</view>

				<!-- 	<view class="btnItem" @click="itemclick" style="margin-top: 30rpx;">
					<view class="btnTitle">
						<image class="i" src="../../static/mine/icon1.png" mode=""></image>
						个人信息
					</view>

					<image src="../../static/service/youjiantou.png" mode=""></image>
					
				</view>
				<view class="line">

				</view> -->

				<view class="btnItem" @click="itemclickMyEnroll" style="margin-top: 30rpx;">
					<view class="btnTitle">
						<image class="i" src="../../static/mine/icon2.png" mode=""></image>
						我的报名
					</view>
					<!-- <view class="btnIcon_iamge"> -->
					<image src="../../static/service/youjiantou.png" mode=""></image>
					<!-- </view> -->
				</view>
				<view class="line"></view>

				<view class="btnItem" @click="itemclickMytext">
					<view class="btnTitle">
						<image class="i" src="../../static/mine/icon3.png" mode=""></image>
						我的测试
					</view>
					<!-- <view class="btnIcon_iamge"> -->
					<image src="../../static/service/youjiantou.png" mode=""></image>
					<!-- </view> -->
				</view>
				<view class="line"></view>

				<view class="btnBox" @click="exitLogin()">退出登录</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			userList: '',
			avatarUrl: '', //用于存储微信头像
			userName: '王杰',
			phone: '13333144889'
		};
	},
	created() {
		const userName = uni.getStorageSync('userName');
		if (userName) {
			this.userName = userName;
		}
	},
	mounted() {
		this.getList();
	},
	methods: {
		onChooseavatar(e) {
			console.log(e, 'llllll');
			// let self = this;
			this.avatarUrl = e.detail.avatarUrl;
			// uni.showLoading({
			// 	title: '加载中'
			// });
			// uni.uploadFile({
			// 	url: '后台uploadFile接口',
			// 	filePath: avatarUrl,
			// 	name: 'file',
			// 	header: {
			// 		token: '自己的token',
			// 	},
			// 	success: uploadFileRes => {
			// 		// 注意：这里返回的uploadFileRes.data 为JSON 需要自己去转换
			// 		let data = JSON.parse(uploadFileRes.data);
			// 		if (data.code === 0) {
			// 			this.avatarUrl = data.data;
			// 		}
			// 	},
			// 	fail: (error) => {
			// 		uni.showToast({
			// 			title: error,
			// 			duration: 2000
			// 		});
			// 	},
			// 	complete: () => {
			// 		uni.hideLoading();
			// 	}
			// });
		},
		// 我的报名的回调函数
		itemclickMyEnroll() {
			uni.navigateTo({
				url: '../../subpkg/enrollResult/enrollResult',
				success: res => {},
				fail: () => {},
				complete: () => {}
			});
		},
		// 我的测试
		itemclickMytext() {
			uni.navigateTo({
				url: '../../subpkg/myText/index',
				success: res => {},
				fail: () => {},
				complete: () => {}
			});
		},

		// 退出登录
		exitLogin() {
			const value = uni.getStorageSync('accessToken');
			if (value) {
				uni.removeStorageSync('Id');
				uni.removeStorageSync('userName');
				uni.removeStorageSync('accessToken');
				uni.removeStorageSync('__DC_STAT_UUID');
				uni.reLaunch({
					url: '/pages/login/index',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.mineBox {
	position: relative;

	.bgBox {
		width: 100%;
		position: absolute;
		height: 461rpx;
		background-color: #3b72ec;
		// background-image: url();
		// background-size: 100% 100%;
	}

	.mineMain {
		padding: 0rpx 32rpx;
		padding-top: 10vh;
		z-index: 5;
		position: relative;
		// 获取微信头像
		.avatarUrl {
			// padding: 80rpx 0 40rpx;
			// background: #fff;

			button {
				background: transparent;
				line-height: 80rpx;
				height: auto;
				width: auto;
				padding: 20rpx 30rpx;
				margin: 0;
				display: flex;
				justify-content: center;
				align-items: center;

				.refreshIcon {
					width: 160rpx;
					height: 160rpx;
					border-radius: 50%;
				}

				.jt {
					width: 14rpx;
					height: 28rpx;
				}
			}
		}

		.imgHead {
			width: 200rpx;
			height: 200rpx;
			border-radius: 50%;
		}

		.nameBox {
			text-align: center;
			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			margin-top: 30rpx;
			color: #ffffff;
		}

		.codeBox {
			text-align: center;
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #2c3445;
			line-height: 36rpx;
			margin-bottom: 88rpx;
		}

		.btnItem {
			display: flex;
			justify-content: space-between;
			padding: 44rpx 0rpx;

			.btnTitle {
				display: flex;
				align-items: center;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #2c3445;
				line-height: 36rpx;

				.i {
					width: 44rpx;
					height: 44rpx;
					margin-right: 14rpx;
				}
			}

			.btnItem_text {
				// float: right;
				// margin-left: 480rpx;
				margin-right: 19rpx;

				text {
					// margin-left: 460rpx;
					font-size: 32rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
					line-height: 36rpx;
				}
			}

			// .btnIcon_iamge {
			// 	width: 10rpx;
			// 	height: 18rpx;

			image {
				width: 10rpx;
				height: 18rpx;
			}

			// }
		}

		.line {
			width: 100%;
			height: 1px;
			background-color: #ebebeb;
		}

		.btnBox {
			margin-top: 12rpx;
			height: 91rpx;
			background: #dce0f0;
			border-radius: 8rpx;
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #2c3445;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
}
</style>
